package com.yilin.tms.core.entity.capital;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yilin.tms.core.commons.base.BaseDataEntity;
import com.yilin.tms.core.commons.annotation.Explain;

import javax.persistence.*;
import java.util.Date;

@Entity
@Table(name = "capital_trade_record")
@TableName(value = "capital_trade_record")
public class TradeRecord extends BaseDataEntity {
    /**
     * 交易类型
     */
    public enum PayType {
        wxPay(0, "微信"),
        alipay(1, "支付宝"),
        unionPay(2, "云闪付"),
        quickPay(3, "快捷支付"),
        creditPay(4, "授信支付"),
        bankPay(5, "银行支付"),
        rbBagPay(6, "荣邦供应链钱包支付");//新版本丢弃，移植用
        @EnumValue
        public Integer index;
        public String name;

        PayType(Integer index, String name) {
            this.index = index;
            this.name = name;
        }
    }

    /**
     * 银行类型
     * 银企直连
     * */
    public enum BankType {
        none(0, "非直连支付或线下汇款"),
        cmbcBankPay(1, "民生银行银企直连"),
        pabBankPay(2, "平安银行银企直连"),
        psbBankPay(3, "邮政银行银企直连");
        @EnumValue
        public Integer index;
        public String name;

        BankType(Integer index, String name) {
            this.index = index;
            this.name = name;
        }
    }

    /**
     * 交易类型
     */
    public enum TradeType {
        payment(0, "货主付款"),//货主付款
        settlement(1, "平台结款"),//付款人为平台
        service(2, "服务费"),//付款人微平台
        refund(3, "退款"),//货主退款
        freeze(4, "冻结"),
        thaw(5, "解冻"),
        transfer(6, "普通转账"),
        refundFee(7, "手续费退费"),
        unknown(8, "不明交易");
        @EnumValue
        public Integer index;
        public String name;

        TradeType(Integer index, String name) {
            this.index = index;
            this.name = name;
        }
    }

    /**
     * 交易状态
     */
    public enum TradeStatus {
        create(0, "创建"),
        audit(1, "审核中"),
        auditSuccess(2, "审核成功"),
        auditFail(3, "审核失败"),
        paySuccess(4, "交易成功"),
        payFail(5, "交易失败"),
        wait(6, "第三方处理中"),
        close(7, "交易关闭"),
        doubt(8, "交易存疑中"),
        check(9, "校验数据");//30分钟内有效

        @EnumValue
        public Integer index;
        public String name;

        TradeStatus(Integer index, String name) {
            this.index = index;
            this.name = name;
        }
    }

    //省运管 资金单 创建状态
    public enum TmsCapitalDataState {
        needless(0, "无需创建"),
        wait(1, "等待创建"),
        creating(2, "创建中"),
        success(3, "创建成功"),
        error(4, "创建失败");
        @EnumValue
        public Integer index;
        public String name;

        TmsCapitalDataState(Integer index, String name) {
            this.index = index;
            this.name = name;
        }
    }
    /**
     * 预支付单，同时支付多个请用“,"号隔开
     */
    @Column(name = "order_payment_ids", columnDefinition = "TEXT")
    private String orderPaymentIds;//预支付单ID
    @Column(name = "order_payment_data", columnDefinition = "TEXT")
    private String orderPaymentData;//预支付单数据包 格式[{单号/金额/}] [{"paymentNo":"YF1694500097125121","paymentCost":0.04,"transportNo":"TS1694490562155143","robOrderNo":"","goodsOrderNo":""}]
    @Column(name = "tms_capital_data_state")
    private TmsCapitalDataState tmsCapitalDataState; //省运管 车辆信息单 提交状态
    /**
     * 交易信息
     */
    @Column(name = "trans_name")
    private String transName;//交易名称
    @Column(name = "trade_type")
    private TradeType tradeType;//交易类型
    @Column(name = "trade_status")
    private TradeStatus tradeStatus;//交易状态
    @Column(name = "pay_type")
    private PayType payType;//支付方式
    @Column(name = "bank_type")
    private BankType bankType;//银行类型
    @Column(name = "remark")
    private String remark;//备注
    @Column(name = "trade_fail_msg")
    private String tradeFailMsg;//交易失败信息
    /**
     * 交易数据
     */
    @Column(name = "trade_cost")
    private Double tradeCost;//原交易金额

    @Column(name = "technical_fee")
    private Double technicalFee=0D;//交易技术服务费用
    @Column(name = "plat_technical_fee")
    private Double platTechnicalFee = 0D; //平台（网货>孵化）交易技术服务费用
    @Column(name = "zone_technical_fee")
    private Double zoneTechnicalFee = 0D; //平台（孵化>社区）交易技术服务费用
    @Column(name = "money")
    private Double money;//支付费用 = tradeCost-technicalFee

    @Column(name = "trade_no")
    private String tradeNo;//交易单号(平台流水号)
    @Column(name = "trade_code")
    private String tradeCode;//交易码 (平台交易码-8位数纯数字)
    @Column(name = "bank_flow_no")
    @Explain("银行流水号")
    private String bankFlowNo;//银行流水号（银行/第三方)
    @Column(name = "original_payment_order_id")
    private String originalPaymentOrderId;// 退款时 原交易单ID
    @Column(name = "notified_refresh")
    private Boolean notifiedRefresh = false;  //是否已通知刷新 交易成功时刷新且仅刷新一次
    @Column(name = "batch_trade_no")
    private String batchTradeNo;  //批量付款单号 如果为同一批次批量付款必填

    /**
     * 付款方
     */
    @Column(name = "payment_organize_id")
    private String paymentOrganizeId;//付款组织ID
    @Column(name = "payment_organize_name")
    private String paymentOrganizeName;//付款组织名称
    @Column(name = "payment_capital_account")
    @Explain("付款账号")
    private String paymentCapitalAccount;//付款资金结算户账号/卡号/微信ID/支付宝ID 等
    /**
     * 收款方
     */
    @Column(name = "income_organize_id")
    private String incomeOrganizeId;//transfer:收款组织ID
    @Column(name = "income_organize_name")
    private String incomeOrganizeName;//transfer:收款组织名称
    @Column(name = "income_capital_account")
    private String incomeCapitalAccount;//收款资金结算户账号/卡号/微信ID/支付宝ID 等
    /**
     * 付款操作人
     */
    @Explain("付款锁定")
    @Column(name = "opt_lock")
    private Boolean optLock = false;
    @Column(name = "opt_lock_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(fill = FieldFill.UPDATE)
    private Date optLockTime;
    @Column(name = "opt_user_id")
    @TableField(fill = FieldFill.UPDATE)
    private String optUserId;//付款操作人ID
    @Column(name = "opt_user_name")
    @TableField(fill = FieldFill.UPDATE)
    private String optUserName;//付款操作人名称
    /**
     * 审核操作人
     */
    @Explain("审核锁定")
    @Column(name = "verify_lock")
    private Boolean verifyLock = false;
    @Column(name = "verify_lock_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date verifyLockTime;
    @Column(name = "verify_user_id")
    private String verifyUserId;//审核操作人ID
    @Column(name = "verify_user_name")
    private String verifyUserName;//审核操作人名称
    /**
     * 时间线
     */
    @Column(name = "initiate_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date initiateTime;// 发起时间
    @Column(name = "closing_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date closingTime;// 关闭时间 [请在关闭时间之前完成付款]
    @Column(name = "finish_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Explain("付款到账时间")
    private Date finishTime;// 完成时间

    @Explain("是否对账")
    @Column(name = "reconciliation")
    private Boolean reconciliation = false;

    @Transient //付款人银行卡
    @TableField(exist = false)
    private BankCard paymentBackCard;
    @Transient //收款人银行卡
    @TableField(exist = false)
    private BankCard collectionBackCard;

    public Double getTradeCost() {
        return tradeCost;
    }

    public void setTradeCost(Double tradeCost) {
        this.tradeCost = tradeCost;
    }

    public Double getTechnicalFee() {
        return technicalFee;
    }

    public void setTechnicalFee(Double technicalFee) {
        this.technicalFee = technicalFee;
    }

    public Double getPlatTechnicalFee() {
        return platTechnicalFee;
    }

    public void setPlatTechnicalFee(Double platTechnicalFee) {
        this.platTechnicalFee = platTechnicalFee;
    }

    public Double getZoneTechnicalFee() {
        return zoneTechnicalFee;
    }

    public void setZoneTechnicalFee(Double zoneTechnicalFee) {
        this.zoneTechnicalFee = zoneTechnicalFee;
    }

    public Boolean getReconciliation() {
        return reconciliation;
    }

    public void setReconciliation(Boolean reconciliation) {
        this.reconciliation = reconciliation;
    }
    public BankType getBankType() {
        return bankType;
    }

    public void setBankType(BankType bankType) {
        this.bankType = bankType;
    }

    public BankCard getPaymentBackCard() {
        return paymentBackCard;
    }

    public void setPaymentBackCard(BankCard paymentBackCard) {
        this.paymentBackCard = paymentBackCard;
    }

    public BankCard getCollectionBackCard() {
        return collectionBackCard;
    }

    public void setCollectionBackCard(BankCard collectionBackCard) {
        this.collectionBackCard = collectionBackCard;
    }

    public String getBatchTradeNo() {
        return batchTradeNo;
    }

    public String getTradeCode() {
        return tradeCode;
    }

    public void setTradeCode(String tradeCode) {
        this.tradeCode = tradeCode;
    }

    public void setBatchTradeNo(String batchTradeNo) {
        this.batchTradeNo = batchTradeNo;
    }

    public String getOrderPaymentData() {
        return orderPaymentData;
    }

    public void setOrderPaymentData(String orderPaymentData) {
        this.orderPaymentData = orderPaymentData;
    }

    public String getOrderPaymentIds() {
        return orderPaymentIds;
    }

    public void setOrderPaymentIds(String orderPaymentIds) {
        this.orderPaymentIds = orderPaymentIds;
    }

    public String getTransName() {
        return transName;
    }

    public void setTransName(String transName) {
        this.transName = transName;
    }

    public TradeType getTradeType() {
        return tradeType;
    }

    public void setTradeType(TradeType tradeType) {
        this.tradeType = tradeType;
    }

    public TradeStatus getTradeStatus() {
        return tradeStatus;
    }

    public void setTradeStatus(TradeStatus tradeStatus) {
        this.tradeStatus = tradeStatus;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public PayType getPayType() {
        return payType;
    }

    public void setPayType(PayType payType) {
        this.payType = payType;
    }

    public String getTradeFailMsg() {
        return tradeFailMsg;
    }

    public void setTradeFailMsg(String tradeFailMsg) {
        this.tradeFailMsg = tradeFailMsg;
    }

    public TmsCapitalDataState getTmsCapitalDataState() {
        return tmsCapitalDataState;
    }

    public void setTmsCapitalDataState(TmsCapitalDataState tmsCapitalDataState) {
        this.tmsCapitalDataState = tmsCapitalDataState;
    }

    public Double getMoney() {
        return money;
    }

    public void setMoney(Double money) {
        this.money = money;
    }

    public String getTradeNo() {
        return tradeNo;
    }

    public void setTradeNo(String tradeNo) {
        this.tradeNo = tradeNo;
    }

    public String getBankFlowNo() {
        return bankFlowNo;
    }

    public void setBankFlowNo(String bankFlowNo) {
        this.bankFlowNo = bankFlowNo;
    }

    public String getOriginalPaymentOrderId() {
        return originalPaymentOrderId;
    }

    public void setOriginalPaymentOrderId(String originalPaymentOrderId) {
        this.originalPaymentOrderId = originalPaymentOrderId;
    }

    public Boolean getNotifiedRefresh() {
        return notifiedRefresh;
    }

    public void setNotifiedRefresh(Boolean notifiedRefresh) {
        this.notifiedRefresh = notifiedRefresh;
    }

    public String getPaymentOrganizeId() {
        return paymentOrganizeId;
    }

    public void setPaymentOrganizeId(String paymentOrganizeId) {
        this.paymentOrganizeId = paymentOrganizeId;
    }

    public String getPaymentOrganizeName() {
        return paymentOrganizeName;
    }

    public void setPaymentOrganizeName(String paymentOrganizeName) {
        this.paymentOrganizeName = paymentOrganizeName;
    }

    public String getPaymentCapitalAccount() {
        return paymentCapitalAccount;
    }

    public void setPaymentCapitalAccount(String paymentCapitalAccount) {
        this.paymentCapitalAccount = paymentCapitalAccount;
    }

    public String getIncomeOrganizeId() {
        return incomeOrganizeId;
    }

    public void setIncomeOrganizeId(String incomeOrganizeId) {
        this.incomeOrganizeId = incomeOrganizeId;
    }

    public String getIncomeOrganizeName() {
        return incomeOrganizeName;
    }

    public void setIncomeOrganizeName(String incomeOrganizeName) {
        this.incomeOrganizeName = incomeOrganizeName;
    }

    public String getIncomeCapitalAccount() {
        return incomeCapitalAccount;
    }

    public void setIncomeCapitalAccount(String incomeCapitalAccount) {
        this.incomeCapitalAccount = incomeCapitalAccount;
    }

    public Boolean getOptLock() {
        return optLock;
    }

    public void setOptLock(Boolean optLock) {
        this.optLock = optLock;
    }

    public Date getOptLockTime() {
        return optLockTime;
    }

    public void setOptLockTime(Date optLockTime) {
        this.optLockTime = optLockTime;
    }

    public String getOptUserId() {
        return optUserId;
    }

    public void setOptUserId(String optUserId) {
        this.optUserId = optUserId;
    }

    public String getOptUserName() {
        return optUserName;
    }

    public void setOptUserName(String optUserName) {
        this.optUserName = optUserName;
    }

    public Boolean getVerifyLock() {
        return verifyLock;
    }

    public void setVerifyLock(Boolean verifyLock) {
        this.verifyLock = verifyLock;
    }

    public Date getVerifyLockTime() {
        return verifyLockTime;
    }

    public void setVerifyLockTime(Date verifyLockTime) {
        this.verifyLockTime = verifyLockTime;
    }

    public String getVerifyUserId() {
        return verifyUserId;
    }

    public void setVerifyUserId(String verifyUserId) {
        this.verifyUserId = verifyUserId;
    }

    public String getVerifyUserName() {
        return verifyUserName;
    }

    public void setVerifyUserName(String verifyUserName) {
        this.verifyUserName = verifyUserName;
    }

    public Date getInitiateTime() {
        return initiateTime;
    }

    public void setInitiateTime(Date initiateTime) {
        this.initiateTime = initiateTime;
    }

    public Date getClosingTime() {
        return closingTime;
    }

    public void setClosingTime(Date closingTime) {
        this.closingTime = closingTime;
    }

    public Date getFinishTime() {
        return finishTime;
    }

    public void setFinishTime(Date finishTime) {
        this.finishTime = finishTime;
    }
}
